package com.yycx.module.bus.provider.controller.hy;

import cn.hutool.core.map.MapUtil;
import com.yycx.common.security.OpenHelper;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import com.yycx.common.mybatis.model.*;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RestController;
import com.yycx.common.springmvc.base.BaseController;
import com.yycx.module.bus.client.entity.hy.BusPaymentDetails;
import com.yycx.module.bus.provider.service.hy.BusPaymentDetailsService;


/**
 * 付款通知单明细控制器
 *
 * @author flyme
 * @date 2023-12-05
 */
@RestController
@RequestMapping("/bus/paymentDetails/")
public class BusPaymentDetailsController extends BaseController<BusPaymentDetailsService, BusPaymentDetails>  {

    @ApiOperation(value = "付款通知单明细-分页列表", notes = "付款通知单明细分页列表")
    @GetMapping(value = "page")
    public ResultBody pageList(@RequestParam(required = false) Map params) {
        return bizService.pageList(params);
    }

    @ApiOperation(value = "付款通知单明细-列表", notes = "付款通知单明细列表")
    @GetMapping(value = "list")
    public ResultBody list(@RequestParam(required = false) Map params) {
        return bizService.listEntityMap(params);
    }

    @ApiOperation(value = "付款通知单明细-添加", notes = "添加付款通知单明细")
    @PostMapping(value = "save")
    public ResultBody save(@RequestParam(required = false) Map params) {
        return bizService.add(params);
    }

    @ApiOperation(value = "付款通知单明细-更新", notes = "更新付款通知单明细")
    @PostMapping(value = "update")
    public ResultBody update(@RequestParam(required = false) Map params) {
        return bizService.edit(params);
    }

    @ApiOperation(value = "付款通知单明细-删除", notes = "删除付款通知单明细")
    @PostMapping(value = "remove")
    public ResultBody remove(@RequestParam(required = false) Map params) {
        return bizService.delete(params);
    }


    @ApiOperation(value = "付款通知单明细-详情", notes = "付款通知单明细详情")
    @GetMapping(value = "get")
    public ResultBody get(@RequestParam(required = false) Map params) {
        return bizService.get(params);
    }

    @ApiOperation(value = "获取分解金额信息", notes = "获取分解金额信息")
    @GetMapping(value = "getAmountInfo")
    public ResultBody getAmountInfo(Long paymentId,Long paymentDetailsId) {
        return bizService.getAmountInfo(paymentId,paymentDetailsId);
    }

    /**
     * 导出数据
     *
     * @param params
     * @param request
     * @param response
     */
    @PostMapping(value = "export")
    public void export(@RequestParam(required = false) Map params, HttpServletRequest request, HttpServletResponse response) {
        String companyName = OpenHelper.getAttr("companyName", String.class);
        String handlerName = MapUtil.getStr(params, "handlerName");
        String fileName = MapUtil.getStr(params, "fileName");
        bizService.export(params, request, response, companyName + "-" + fileName, fileName, handlerName);
    }


}
